<include file="Public/min-header"/>
<div class="wrapper">
 <include file="Public/breadcrumb"/>
 <style>#search-form > .form-group{margin-left: 10px;}</style>
  <!-- Main content -->
  <section class="content">
    <div class="container-fluid"> 
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title"><i class="fa fa-list"></i> 商品促销&nbsp;&nbsp;（一个商品只能有一个活动）
        </div>
        <div class="panel-body">
          <div class="navbar navbar-default">
              <form action="" id="search-form2" class="navbar-form form-inline" method="post" onsubmit="return false">
			
           
                                  
                <div class="form-group">
                  <div class="input-group">
                    <input type="text" name="key_word" value="" placeholder="搜产品" id="input-order-id" class="form-control">
                  </div>
                </div>
                <div class="form-group">
                  <div class="input-group">
                    <input type="text" name="dp_word" value="" placeholder="搜店铺" id="input-order-id" class="form-control">
                  </div>
                </div>
              
                  <div class="form-group">
                      <div class="input-group">
                          <input type="text" name="cat_key" value="" placeholder="三级分类搜索"  class="form-control">
                      </div>
                  </div>
               <div class="form-group">
                  <select name="prom_status" id="prom_status" class="form-control">
                        <option value="">是否在活动</option>
                        <option value="1">是</option>
                        <option value="2">否</option>
                  </select>
                </div>
                <!--<div class="form-group">-->
                <!--  <select name="cat_id1" id="cat_id1" class="form-control">-->
                <!--    <option value="">所有一级分类</option>-->
                <!--        <volist name="goods_category" id='v'>-->
                <!--            <option value="{$v['id']}"  > {$v['name']}</option>-->
                <!--        </volist>-->
                <!--  </select>-->
                <!--</div>-->
                  <div class="form-group">
                      <select name="cat_id2" id="cat_id2" class="form-control">
                          <option value="">所有二级分类</option>
                          <volist name="goods_category2" id='v'>
                              <option value="{$v['id']}"  > {$v['name']}</option>
                          </volist>
                      </select>
                  </div>
                  <div class="form-group">
                      <select name="cat_id3" id="cat_id3" class="form-control">
                          <option value="">所有三级分类</option>
                          <volist name="goods_category3" id='v'>
                              <option value="{$v['id']}"  > {$v['name']}</option>
                          </volist>
                      </select>
                  </div>
                <!--排序规则-->
                <input type="hidden" name="orderby1" value="goods_id" />
                <input type="hidden" name="orderby2" value="desc" />
                <button type="submit" onclick="ajax_get_table('search-form2',1)" id="button-filter search-order" class="btn btn-primary"><i class="fa fa-search"></i> 筛选</button>
              </form>
          </div>
          <div id="ajax_return"> </div>
        </div>
      </div>
    </div>
    <!-- /.row --> 
  </section>
  <!-- /.content --> 
</div>
<!-- /.content-wrapper -->
<script>
    $(document).ready(function () {
        // ajax 加载商品列表
        ajax_get_table('search-form2', 1);

});

    // ajax 抓取页面 form 为表单id  page 为当前第几页
    function ajax_get_table(form, page) {
        cur_page = page; //当前页面 保存为全局变量
        $.ajax({
            type: "POST",
            url: "/index.php?m=Admin&c=Promotion&a=ajaxprom_goods&p=" + page,//+tab,
            data: $('#' + form).serialize(),// 你的formid
            success: function (data) {
                $("#ajax_return").html('');
                $("#ajax_return").append(data);
            }
        });
    }

    // 点击排序
    function sort(field) {
        $("input[name='orderby1']").val(field);
        var v = $("input[name='orderby2']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='orderby2']").val(v);
        ajax_get_table('search-form2', cur_page);
    }

  

    //获取选中商品id
    function get_select_goods_id_str() {
        if ($('input[name="goods_id\[\]"]:checked').length == 0)
            return false;
        var goods_arr = Array();
        $('input[name="goods_id\[\]"]:checked').each(function () {
            goods_arr.push($(this).val());
        });
        var goods_id_str = goods_arr.join(',');
        return goods_id_str
    }

    act = '';//操作变量
    //批量操作
    function fuc_change(obj) {
        var fuc_val = $(obj).children('option:selected').val();
        if (fuc_val == 0) {
            //推荐
            act = 'recommend';
            $('#act_button').removeClass('disabled');
            reset_state();
        } else if (fuc_val == 1) {
            act = 'new';
            $('#act_button').removeClass('disabled');
            reset_state();
            //新品
        } else if (fuc_val == 2) {
            act = 'hot';
            $('#act_button').removeClass('disabled');
            reset_state();
            //热卖
        } else if (fuc_val == 3) {
            act = 'examine';
            $('#state_id').show();
            $('#act_button').addClass('disabled');
            $("#state_id option:first").prop("selected", 'selected');
            //审核商品
        } else {
            act = '';
            $('#act_button').addClass('disabled');
            reset_state();
            //恢复默认
        }
    }

    //重置审核操作
    function reset_state() {
        $("#state_id option:first").prop("selected", 'selected');
        $('#state_id').hide();
    }

    //审核操作
    function state_change(obj) {
        var state_val = $(obj).children('option:selected').val();
        if (state_val == '') {
            $('#act_button').addClass('disabled');
        } else {
            $('#act_button').removeClass('disabled');
        }
    }

    //批量操作提交
    function act_submit() {
        //prompt层
        var ids = get_select_goods_id_str();
        if (ids == false) {
            layer.alert('请勾选要操作的商品', {icon: 2});
            return;
        }
        // var text = prompt('请输入操作备注', '填写操作备注,可不填');
        var goods_state = $('#state_id').children('option:selected').val();
        var myrul='/index.php/Admin/Promotion/prom_goods_id_info/goods_ids/'+ids;//+myrel;
		$.get(myrul,function(e){
			layer.open({
			  type: 2,
			  shadeClose: true, //点击遮罩关闭
			  title:'添加活动',
			  skin: 'layui-layer-rim', //加上边框
			  area: ['80%', '80%'], //宽高
			  content: myrul
			});
		})
        // if (text != null && text != "") {
        //     $.ajax({
        //         type: "POST",
        //         url: "/index.php?m=Admin&c=goods&a=act",//+tab,
        //         data: {act: act,goods_state:goods_state,goods_ids: ids, reason: text},
        //         dataType: 'json',
        //         success: function (data) {
        //             if(data.status == 1){
        //                 layer.alert(data.msg, {
        //                     icon: 1,
        //                     closeBtn: 0
        //                 }, function(){
        //                     window.location.reload();
        //                 });
        //             }else{
        //                 layer.alert(data.msg, {icon: 2,time: 3000});
        //             }

        //         },
        //         error:function(){
        //             layer.alert('网络异常', {icon: 2,time: 3000});
        //         }
        //     });
        // }
    }


</script>
</body>
</html>